﻿namespace ctolua.Models.Areas
{
    /// <summary>
    /// 区域
    /// </summary>
    public class MArea
    {
        /// <summary>
        /// 区域实体
        /// </summary>
        public Area area { get; set; }
        public MArea()
        {

        }
        public MArea(Area area)
        {
            this.area = area;
        }
        public static MArea obj(int id)
        {
            return new MArea(id);
        }
        public MArea(int id)
        {
            this.area = game_api.get_rec_area_by_res_id(id);
        }
        /// <summary>
        /// 获取区域内单位数量
        /// </summary>
        public int? get_unit_num_in_area => game_api.get_unit_num_in_area(this.area);

        /// <summary>
        /// 获得区域天气
        /// </summary>
        public int? get_area_weather => game_api.get_area_weather(this.area);

        /// <summary>
        /// 删除区域
        /// </summary>
        public void del() => game_api.remove_area(this.area);
        /// <summary>
        /// 设置区域天气
        /// </summary>
        /// <param name="weather_type ">  天气类型   </param>
        public void update_area_weather(int weather_type) => game_api.update_area_weather(this.area, weather_type);
        /// <summary>
        /// 设置区域碰撞
        /// </summary>
        /// <param name="is_add ">  添加/去除   </param>
        /// <param name="ground_channel ">  地面碰撞   </param>
        /// <param name="air_channel ">  飞行碰撞   </param>
        public void set_area_collision(bool? is_add, bool? ground_channel, bool? air_channel) => game_api.set_area_collision(this.area, is_add, ground_channel, air_channel);
        /// <summary>
        /// 给区域添加tag
        /// </summary>
        /// <param name="tag ">  tag   </param>
        public void add_area_tag(string tag) => game_api.add_area_tag(this.area, tag);
        /// <summary>
        /// 给区域移除tag
        /// </summary>
        /// <param name="tag ">  tag   </param>
        public void remove_area_tag(string tag) => game_api.remove_area_tag(this.area, tag);
        /// <summary>
        /// 判断点是否在区域内
        /// </summary>
        /// <param name="point ">  点   </param>
        /// <returns>点是否在区域中</returns>
        public void judge_point_in_area(Point point) => game_api.judge_point_in_area(point, this.area);
        /// <summary>
        /// 替换区域中的指定地形纹理
        /// </summary>
        /// <param name="texture_type ">  纹理类型   </param>
        /// <param name="new_texture_type ">  新纹理类型   </param>
        public void replace_point_texture(int? texture_type, int? new_texture_type) => game_api.replace_point_texture(this.area, texture_type, new_texture_type);
        /// <summary>
        /// 获取区域内玩家所有单位id列表
        /// </summary>
        /// <param name="role ">  玩家   </param>
        /// <returns>单位id列表</returns>
        public UnitGroup get_unit_group_belong_to_player_in_area(Role role) => game_api.get_unit_group_belong_to_player_in_area(this.area, role);
        /// <summary>
        /// 得到区域内的单位id列表
        /// </summary>
        /// <returns>单位ID列表</returns>
        public dynamic get_unit_group_in_area() => game_api.get_unit_group_in_area(this.area);
        /// <summary>
        /// 得到区域内的物品对象id列表
        /// </summary>
        /// <returns>物品对象ID列表</returns>
        public dynamic get_item_group_in_area() => game_api.get_item_group_in_area(this.area);
        /// <summary>
        /// 获取区域内的可破坏物列表
        /// </summary>
        /// <param name="area"> 区域对象 </param>
        /// <param name="sort_type"> 筛选规则 </param>
        /// <returns>可破坏物列表</returns>
        public dynamic get_all_dest_in_area(int? sort_type) => game_api.get_all_dest_in_area(this.area, sort_type);
    }
}
